package poker;

/**
 * @author Taavet Tamm
 * @category poker app
 * @version %I% %G%
 * Information about a player
 */
public class PokerPlayer {
	private String name;
	private int score;
	private Card card1;
	private Card card2;
	private String status;
	private int position;
	private int bet;
	private int toCall;
	private int handStrength;

	public int getToCall() {
		return toCall;
	}
	public void setToCall(int toCall) {
		this.toCall = toCall;
	}
	public void doAction(int dealerPosition, int bet) {
		if (this.toCall == 0) {
			this.setStatus("check");
		} else {
			//TODO: implement somekind of logic for raises and calls
			int randomAction = (int)(10.0 * Math.random());
			if (randomAction > 5) this.setStatus("fold");
			else this.doCallAction();
		}
	}
	public void setBet(int bet) {
		this.bet = bet;
		this.toCall -= bet;
	}
	
	public void doCallAction() {
		if (this.toCall == 0) this.status = "check";
		else {
			this.score -= this.toCall;
			this.toCall = 0;
			this.status = "call";
		}
	}
	
	public void doRaiseAction(int amount) {
		this.score -= this.toCall + amount;
		this.toCall = 0;
		this.status = "raise";
	}
	//Takes flop and finds the best hand
	public void findBestHand(Card card1,Card card2,Card card3,Card card4,Card card5) {
		//TODO: import evaluator package
		//convert Cards to evaluator CardSet and evaluate.
		this.handStrength = (int)(10.0 * Math.random());
	}
	
	public boolean isBigBlind(int dealer) {
		if (dealer == 9 && this.position == 1) return true;
		else if (dealer == 8 && this.position == 0) return true;
		else if (dealer + 2 == this.position) return true;
		else return false;
	}
	
	public void setPosition(int position) {
		this.position = position;
	}	
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public Card getCard1() {
		return card1;
	}
	public void setCard1(Card card1) {
		this.card1 = card1;
	}
	public Card getCard2() {
		return card2;
	}
	public void setCard2(Card card2) {
		this.card2 = card2;
	}
	public PokerPlayer(String name, int score) {
		this.name = name;
		this.score = score;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}
	public int getHandStrength() {
		return this.handStrength;
	}
	public int getBet() {
		return this.bet;
	}
}
